<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.13"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>PROGC - Labs: src/test_utils.c File Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">PROGC - Labs
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.13 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
</script>
<div id="main-nav"></div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="dir_68267d1309a1af8e8297ef4c3efbcdba.html">src</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="summary">
<a href="#func-members">Functions</a>  </div>
  <div class="headertitle">
<div class="title">test_utils.c File Reference</div>  </div>
</div><!--header-->
<div class="contents">

<p>Implementation of the test_utils.  
<a href="#details">More...</a></p>
<div class="textblock"><code>#include &lt;stdio.h&gt;</code><br />
<code>#include &lt;stdlib.h&gt;</code><br />
<code>#include &lt;ctype.h&gt;</code><br />
<code>#include &lt;unistd.h&gt;</code><br />
<code>#include &lt;errno.h&gt;</code><br />
<code>#include &lt;assert.h&gt;</code><br />
<code>#include &quot;CUnit/Basic.h&quot;</code><br />
<code>#include &quot;<a class="el" href="test__utils_8h_source.html">test_utils.h</a>&quot;</code><br />
</div>
<p><a href="test__utils_8c_source.html">Go to the source code of this file.</a></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:a3f6e881f0eaa329b3b355ae65250bbac"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="test__utils_8c.html#a3f6e881f0eaa329b3b355ae65250bbac">file_exists</a> (const char file_path[])</td></tr>
<tr class="memdesc:a3f6e881f0eaa329b3b355ae65250bbac"><td class="mdescLeft">&#160;</td><td class="mdescRight">Gracefully checks by means of fopen(..., "r") if a file exists.  <a href="#a3f6e881f0eaa329b3b355ae65250bbac">More...</a><br /></td></tr>
<tr class="separator:a3f6e881f0eaa329b3b355ae65250bbac"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a35cbb394e7d08d81f058acca9b9ecd8b"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="test__utils_8c.html#a35cbb394e7d08d81f058acca9b9ecd8b">remove_file_if_exists</a> (const char file_path[])</td></tr>
<tr class="memdesc:a35cbb394e7d08d81f058acca9b9ecd8b"><td class="mdescLeft">&#160;</td><td class="mdescRight">Removes the given file if it exists.  <a href="#a35cbb394e7d08d81f058acca9b9ecd8b">More...</a><br /></td></tr>
<tr class="separator:a35cbb394e7d08d81f058acca9b9ecd8b"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a1da4a2268d618c918964fc17e9898844"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="test__utils_8c.html#a1da4a2268d618c918964fc17e9898844">assert_lines</a> (const char file[], const char *lines[], size_t n_lines)</td></tr>
<tr class="memdesc:a1da4a2268d618c918964fc17e9898844"><td class="mdescLeft">&#160;</td><td class="mdescRight">Checks if the file content matches exactly the given lines. The lines must contain the new-line character. This is especially important if a file terminates without a new line character.  <a href="#a1da4a2268d618c918964fc17e9898844">More...</a><br /></td></tr>
<tr class="separator:a1da4a2268d618c918964fc17e9898844"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p>Implementation of the test_utils. </p>

<p class="definition">Definition in file <a class="el" href="test__utils_8c_source.html">test_utils.c</a>.</p>
</div><h2 class="groupheader">Function Documentation</h2>
<a id="a1da4a2268d618c918964fc17e9898844"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a1da4a2268d618c918964fc17e9898844">&#9670;&nbsp;</a></span>assert_lines()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void assert_lines </td>
          <td>(</td>
          <td class="paramtype">const char&#160;</td>
          <td class="paramname"><em>file</em>[], </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const char *&#160;</td>
          <td class="paramname"><em>lines</em>[], </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">size_t&#160;</td>
          <td class="paramname"><em>n_lines</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Checks if the file content matches exactly the given lines. The lines must contain the new-line character. This is especially important if a file terminates without a new line character. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">file</td><td>The path to the file to check against the lines. </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">lines</td><td>The array of lines which must match the file content exactly. Newlines must be part of the lines too. </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">n_lines</td><td>The number of lines in the line array. </td></tr>
  </table>
  </dd>
</dl>

<p class="definition">Definition at line <a class="el" href="test__utils_8c_source.html#l00048">48</a> of file <a class="el" href="test__utils_8c_source.html">test_utils.c</a>.</p>

</div>
</div>
<a id="a3f6e881f0eaa329b3b355ae65250bbac"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a3f6e881f0eaa329b3b355ae65250bbac">&#9670;&nbsp;</a></span>file_exists()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int file_exists </td>
          <td>(</td>
          <td class="paramtype">const char&#160;</td>
          <td class="paramname"><em>file_path</em>[]</td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Gracefully checks by means of fopen(..., "r") if a file exists. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">file_path</td><td>The file to check for existence. </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>Returns 0 if the file does not exist, 1 otherwise. </dd></dl>
<dl class="section remark"><dt>Remarks</dt><dd>If the file does not exist, errno was affected. This function takes care of this, i.e. it safes and restores the original errno state. </dd>
<dd>
In case of an error situation, the function fails with a hard assert.h assertion violation. This allows to use the function outside of a tests, e.g. in setup and teardown functions. </dd></dl>

<p class="definition">Definition at line <a class="el" href="test__utils_8c_source.html#l00023">23</a> of file <a class="el" href="test__utils_8c_source.html">test_utils.c</a>.</p>

</div>
</div>
<a id="a35cbb394e7d08d81f058acca9b9ecd8b"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a35cbb394e7d08d81f058acca9b9ecd8b">&#9670;&nbsp;</a></span>remove_file_if_exists()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void remove_file_if_exists </td>
          <td>(</td>
          <td class="paramtype">const char&#160;</td>
          <td class="paramname"><em>file_path</em>[]</td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Removes the given file if it exists. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">file_path</td><td>The path to the file which gets removed if it exists. </td></tr>
  </table>
  </dd>
</dl>
<dl class="section remark"><dt>Remarks</dt><dd>Silently ignores any error. If you are interrested in the errors, set first <em>errno</em> to zero, and check it after the call. </dd>
<dd>
In case of an error situation, the function fails with a hard assert.h assertion violation. This allows to use the function outside of a tests, e.g. in setup and teardown functions. </dd></dl>

<p class="definition">Definition at line <a class="el" href="test__utils_8c_source.html#l00040">40</a> of file <a class="el" href="test__utils_8c_source.html">test_utils.c</a>.</p>

</div>
</div>
</div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.13
</small></address>
</body>
</html>
